﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.项目成果管理.在制品管理.service
{
    public class 在制品管理Service
    {
        public static QcItemsDTO getQcItemsByBatchNo(String batchNo)
        {
            return
                FunctionHelper.JsonDeserialization<QcItemsDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/getQcItemsByBatchNo?batchNo=" + batchNo
                        )
                    );
        }
        public static QcItemsDTO getQcItemsByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<QcItemsDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/getQcItemsByBarcode?barcode=" + barcode
                        )
                    );
        }

        public static void post半成品量尺检查(String orderId, String inspectSizId)
        {
            RestCall.PostHttp(
                        URL.接口url + "/barcode/inspectSizePass?orderId=" + orderId,
                        inspectSizId
                        );
        }
        public static void post半成品设计点检查(String batchNo, DesignItemCheckDTO designItemCheckDTO)
        {
            RestCall.PostHttp(
                        URL.接口url + "/barcode/inspectDesignItemPass?batchNo=" + batchNo,
                        FunctionHelper.JsonSerialization(designItemCheckDTO)
                        );
        }

        /// <summary>
        /// 根据订单取质检项目
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static QcBarcodeItemsDTO getQcItemsDTOByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<QcBarcodeItemsDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/getQcItemsDTOByBarcode?barcode=" + barcode
                        )
                    );
        }
        /// <summary>
        /// 尺寸检验通过
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="inspectSizId"></param>
        /// <returns></returns>
        public static String inspectSizePassByBarcode(String barcode, String inspectSizId)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/barcode/inspectSizePassByBarcode?barcode=" + barcode + "&inspectSizId=" + inspectSizId
                );
        }
        /// <summary>
        /// 设计点通过
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="designItemCheckDTO"></param>
        /// <returns></returns>
        public static String inspectDesignItemPassByBarcode(String barcode, DesignItemCheckDTO designItemCheckDTO)
        {
            return
                RestCall.PostHttp(
                    URL.接口url + "/barcode/inspectDesignItemPassByBarcode?barcode=" + barcode,
                    FunctionHelper.JsonSerialization(designItemCheckDTO)
                );
        }
    }
    
    public class QcItemsDTO
    {
        public String batchNo { get; set; }
        public String styleId { get; set; }
        public String styleSizeCd { get; set; }
        public String styleNameCn { get; set; }
        public String styleImagePath { get; set; }
        public String styleFabricId { get; set; }
        public String materialNameCn { get; set; }
        public String materialCode { get; set; }
        public String materialColor { get; set; }
        public String composition { get; set; }
        public String materialImagePath { get; set; }
        public String remarks { get; set; }
        public List<InspectSizeDTO> inspectSizeDTOS { get; set; } = new List<InspectSizeDTO>();
        public List<DesignItemCheckDTO> designItemCheckDTOS { get; set; } = new List<DesignItemCheckDTO>();
        public QcItemsDTO()
        {

        }
    }
    /// <summary>
    /// barcode取质检项的新DTO
    /// </summary>
    public class QcBarcodeItemsDTO
    {
        public String barcode { get; set; }
        public String batchNo { get; set; }
        /**
         * 款式信息
         */
        public String styleId { get; set; }
        public String styleSizeCd { get; set; }
        public String styleNameCn { get; set; }
        public String styleImagePath { get; set; }
        /**
         * 面料信息
         */
        public String styleFabricId { get; set; }
        public String materialNameCn { get; set; }
        public String materialCode { get; set; }
        public String materialColor { get; set; }
        public String composition { get; set; }
        public String materialImagePath { get; set; }
        /**
         * 备注
         */
        public String remarks { get; set; }
        /**
         * 尺寸
         */
        public List<InspectSizeDTO> inspectSizeDTOS { get; set; } = new List<InspectSizeDTO>();
        /**
         * 设计点
         */
        public List<DesignItemCheckDTO> designItemCheckDTOS { get; set; } = new List<DesignItemCheckDTO>();
        public QcBarcodeItemsDTO()
        {

        }
    }

    public class InspectSizeDTO
    {
        public String id { get; set; }//id
        public int index { get; set; }//序号
        public String itemNameCn { get; set; }//大分类名称
        public Double garmentSize { get; set; }//成衣尺寸
        public String parentId { get; set; }//父id
        public Boolean ifPass { get; set; }//是否通过
        public Boolean hasFitValue { get; set; }//是否人尺寸
        public Boolean hasGarmentSize { get; set; }//是否成衣尺寸
        public Boolean hasHalf { get; set; }//是否1/2
        public InspectSizeDTO()
        {

        }
    }

    public class DTO半成品量尺呈现
    {
        public String id { get; set; }//id
        public int index { get; set; }//序号
        public String itemNameCn { get; set; }//大分类名称
        public Double garmentSize { get; set; }//成衣尺寸
        public String parentId { get; set; }//父id
        public String ifPass { get; set; }//是否通过
        public Boolean hasFitValue { get; set; }//是否人尺寸
        public Boolean hasGarmentSize { get; set; }//是否成衣尺寸
        public Boolean hasHalf { get; set; }//是否1/2

        public DTO半成品量尺呈现(InspectSizeDTO dTO)
        {
            this.id = dTO.id;
            this.index = dTO.index;
            this.itemNameCn = dTO.itemNameCn;
            this.garmentSize = dTO.garmentSize;
            this.parentId = dTO.parentId;
            this.ifPass = dTO.ifPass ? "通过" : "未通过";
            this.hasFitValue = dTO.hasFitValue;
            this.hasGarmentSize = dTO.hasGarmentSize;
            this.hasHalf = dTO.hasHalf;
        }
    }

    public class DesignItemCheckDTO
    {
        public String itemTypeNameCn { get; set; }//
        public String itemCd { get; set; }//
        public String itemValue { get; set; }//
        public String optionValue { get; set; }//
        public String name { get; set; }//设计点名称
        public Boolean ifPass { get; set; }//是否通过
        public int index { get; set; }//序号
        public DesignItemCheckDTO()
        {

        }
        public DesignItemCheckDTO(DesignItemCheckVO dTO)
        {
            this.itemTypeNameCn = dTO.itemTypeNameCn;
            this.itemCd = dTO.itemCd;
            this.itemValue = dTO.itemValue;
            this.optionValue = dTO.optionValue;
            this.ifPass = dTO.ifPass;
            this.name = dTO.name;
            this.index = dTO.index;
        }
    }
    public class DTO半成品设计点呈现
    {
        public String itemTypeNameCn { get; set; }//
        public String itemCd { get; set; }//
        public String itemValue { get; set; }//
        public String optionValue { get; set; }//
        public String name { get; set; }//设计点名称
        public String ifPass { get; set; }//是否通过
        public int index { get; set; }//序号
        public DTO半成品设计点呈现(DesignItemCheckDTO dTO)
        {
            this.itemTypeNameCn = dTO.itemTypeNameCn;
            this.itemCd = dTO.itemCd;
            this.itemValue = dTO.itemValue;
            this.optionValue = dTO.optionValue;
            this.name = dTO.name;
            this.ifPass = dTO.ifPass ? "通过" : "未通过";
            this.index = dTO.index;
        }
    }
}
